package com.wuxiaoge.dao;

import com.wuxiaoge.dto.TaskDto;
import com.wuxiaoge.entity.Task;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

import java.util.List;

public interface TaskDao extends JpaRepository<Task,Long>, JpaSpecificationExecutor<Task> {

    @Query(value = "select t.id,t.task_name,t.task_detail,t.project_id,p.project_name " +
            " from tb_task t inner join tb_project p on t.project_id = p.project_id " +
            "where t.id =:id and t.task_name like CONCAT('%',:taskName,'%')",nativeQuery = true)
    List<TaskDto> findTaskList(@Param("taskName") String taskName,@Param("id") Integer id);

}

